package com.ty.common.core.dataScope;

import com.alibaba.ttl.TransmittableThreadLocal;

/**
 * @描述:
 * @Author: TangYuan
 * @Date: 2025/8/19 14:43
 */
public class ControlThreadLocal {

    protected static final TransmittableThreadLocal<ControlPermissions> LOCAL_CONTROLLER = new TransmittableThreadLocal<>();

    private ControlThreadLocal() {
        throw new IllegalStateException("ControlThreadLocal 类非法");
    }

    public static void set(ControlPermissions permission) {
        LOCAL_CONTROLLER.set(permission);
    }

    public static ControlPermissions get() {
        return LOCAL_CONTROLLER.get();
    }

    public static boolean hasLocal() {
        return LOCAL_CONTROLLER.get() != null;
    }

    public static void clearDataScope() {
        LOCAL_CONTROLLER.remove();
    }

}
